Neighbourhood Watch Victoria survey analysis

In [1]:
#!pip install geopandas
In [2]:
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="darkgrid")
%matplotlib inline
In [3]:
#Read the data
df = pd.read_csv("Copy of HSIMP VIC Quiz Results 030620_2.csv",sep =',')
df.head()
Out[3]:
Name Postcode How safe do you feel when you are in your home? What type of home do you live in? Which of the following external doors does your home have? How well do you know your neighbours? Keys stored out of sight in a secret spot. Spare keys not hidden in obvious places outside the home Keys not kept in locks when not at home Spare key kept with trusted friend, relative or neighbour ... Motion sensor or timed lighting Neighbourhood Watch stickers visible What fences does your property have? Which of the following security measures do you have in place for your front fence and gate Which of the following security measures do you have in place for your rear and side fences and gates. Do you have any outdoor buildings such as sheds, a studio or granny flat? Which of these security measures do you have on your outdoor buildings Does your home have an enclosed garage? What security measures do you have in place for your garage Date
0 Mr. Bilbo L. Baggins Ring-bearer NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 James 3199 NaN House NaN I know them very well and leave a spare key wi... NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2 James 3199 NaN House NaN I know them very well and leave a spare key wi... Yes Yes Yes NaN ... Yes Yes NaN NaN NaN NaN NaN NaN NaN NaN
3 Nick 3189 NaN House NaN I know them to say hello and we talk occasiona... Yes Yes Yes NaN ... Yes Yes NaN NaN NaN NaN NaN NaN NaN NaN
4 wilma 3085 NaN House NaN I know them fairly well, we keep an eye on eac... Yes Yes Yes NaN ... Yes Yes NaN NaN NaN NaN NaN NaN NaN NaN

5 rows × 40 columns

Data Preprocessing

In [4]:
#Drop unneccesary columns
df = df.drop(['Name', 'Date'], axis = 1) 
In [5]:
#Check unique values
for col in df:
    print('Unique values of ' + col)
    print(df[col].unique())
Unique values of Postcode
[nan '3199' '3189' '3085' '3079' '3219' '3019' '3103' '3182' '3931' '3223'
 '3335' '3037' '3026' '3029' '3444' '3198' '3215' '3086' '3046' '3108'
 '3028' '3099' '3197' '3764' '3000' '3844' '66220' '2602' '6000' '3196'
 '3071' '3070' '3016' '3756' '3564' '3608' '3977' '3820' '3939' '3013'
 '3212' '3930' '3111' '3810' '3975' '3978' '3809' '3757' '3806' '3113'
 '3040' '2305' '2114' '3030' '3088' '3109' '3059' '3224' '3130' '3875'
 '3131' '3434' '2207' '3350' '3058' '3170' '3008' '3173' '3754' '3020'
 '3128' '3195' '2740' '19123' '3188' '3136' '3191' '3107' '820' '3336'
 '3074' '3915' '3358' '3148' '3840' '3105' '3204' '3149' '3158' '3174'
 '3031' '3083' '3976' '4814' '3804' '800' '3555' '3064' '3630' '3134'
 '3106' '3138' '3123' '6082' '3936' '3672' '3133' '3666' '3066' '3466'
 '3186' '3178' '3146' '3166' '3144' '3153' '3429' '6171' '3192' '3095'
 '3143' '3081' '3550' '3722' '3226' '3073' '3126' '3104' '3084' '3129'
 '3132' '3161' '3150' '3004' '3171' '3217' '3137' '3024' 'mer' '3461'
 '3918' '3818' '2720' '3172' '3101' '3145' '3036' '3156' '2295' '3802'
 '3824' '110047' '3220' '3551' '3453' '3953' '3995' '3909' '3152' '3089'
 '3068' '3121' '3179' '3690' '3147' '3216' '3018' '3151' '3187' '3093'
 '3791' '3880' '5172' '3155' '3438' '3352' '3163' '3044' '3752' '3033'
 '3094' '3194' '3127' '3356' '3141' '3047' '5064' '3636' '3142' '3400'
 '3122' '3214' '3669' '3181' '3115' '4218' '3579' '3280' '3185' '3175'
 '3162' '3282' '3941' '3206' '3042' '3813' '3629' '3807' '3620' '3205'
 '3631' '3096' '3442' '3783' '3135' '3140' '3910' '3561' '3996' '3193'
 '3337' '3677' '3858' '3043' '3225' '3067' '3102' '3116' '3338' '3621'
 '3340' '3505' '3264' '3015' '3201' '4512' '3165' '3082' '3227' '3371'
 '3825' '3869' '3431' '3023' '3075' '3469' '3793' '3154' '3435' '3305'
 '2151' '3805' '3451' '3124' '3055' '2648' '3184' '3331' '3125' '3787'
 '3012' '3021' '2680' '3351' '3938' '3041' '3034' '3222' '3228' 'Thorne'
 '3926' '3038' '3750' '3850' '3087' '3032' '3078' '3060' '3954' '3011'
 '3437' '3052' '3401' '3498' '3355' '3114' '3803' '3056' '3051' '3523'
 '3276' '3842' '3200' 'Grivas' '3500' '3496' '3796' '3054' '3076' '3580'
 '3671' '3159' '3747' '3039' '3053' '3714' '3490' '6055' '3980' '4817'
 '4655' '3207' '4575' '3911' '3614' '3218' '3300' '3450' '3183' '3922'
 'Rooney' '7310' '3084he' '3377' '3737' '3027' '3160' '4410' '3966' '7268'
 '7901' '3897' '3169' '3167' '7896']
Unique values of How safe do you feel when you are in your home?
[nan  5. 10.  9.  7.  2.  6.  8.  1.  4.  3.]
Unique values of What type of home do you live in?
[nan 'House' 'Unit/Townhouse' 'Farm' 'Apartment']
Unique values of Which of the following external doors does your home have?
[nan 'Front door, Rear door, Side door(s)' 'Front door'
 'Front door, Rear door' 'Front door, Side door(s)' 'Side door(s)'
 'Rear door, Side door(s)' 'Rear door']
Unique values of How well do you know your neighbours?
[nan 'I know them very well and leave a spare key with them'
 'I know them to say hello and we talk occasionally, but that’s it'
 'I know them fairly well, we keep an eye on each other’s places'
 'I don’t know them']
Unique values of Keys stored out of sight in a secret spot.
[nan 'Yes' 'No']
Unique values of Spare keys not hidden in obvious places outside the home
[nan 'Yes' 'No']
Unique values of Keys not kept in locks when not at home
[nan 'Yes' 'No']
Unique values of Spare key kept with trusted friend, relative or neighbour
[nan 'Yes' 'No']
Unique values of Does your home have any security systems?
[nan 'Yes' 'No']
Unique values of Which of the follow systems do you have in place?
[nan 'Motion sensors/detector, Unmonitored security alarm'
 'Unmonitored security alarm'
 'Motion sensors/detector, Monitored security system'
 'Motion sensors/detector, Window or door sensors, Security cameras in entry'
 'Motion sensors/detector, Unmonitored security alarm, Window or door sensors, Security cameras in entry, Security footage stored safely'
 'Unmonitored security alarm, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector'
 'Security cameras in entry, Security footage stored safely'
 'Monitored security system'
 'Motion sensors/detector, Security cameras in entry'
 'Security cameras in entry'
 'Motion sensors/detector, Unmonitored security alarm, Security footage stored safely'
 'Motion sensors/detector, Unmonitored security alarm, Window or door sensors'
 'Motion sensors/detector, Security footage stored safely'
 'Monitored security system, Window or door sensors, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Monitored security system, Security cameras in entry'
 'Motion sensors/detector, Monitored security system, Unmonitored security alarm, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Unmonitored security alarm, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Unmonitored security alarm, Security cameras in entry'
 'Motion sensors/detector, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Monitored security system, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Monitored security system, Security footage stored safely'
 'Monitored security system, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Monitored security system, Window or door sensors'
 'Motion sensors/detector, Monitored security system, Window or door sensors, Security cameras in entry, Security footage stored safely'
 'Unmonitored security alarm, Window or door sensors'
 'Security footage stored safely'
 'Unmonitored security alarm, Security footage stored safely'
 'Monitored security system, Window or door sensors'
 'Monitored security system, Security footage stored safely'
 'Monitored security system, Security cameras in entry'
 'Unmonitored security alarm, Security cameras in entry'
 'Motion sensors/detector, Unmonitored security alarm, Window or door sensors, Security cameras in entry'
 'Motion sensors/detector, Window or door sensors'
 'Motion sensors/detector, Window or door sensors, Security cameras in entry, Security footage stored safely'
 'Window or door sensors'
 'Motion sensors/detector, Window or door sensors, Security footage stored safely']
Unique values of I keep a phone in my bedroom at night
[nan 'Yes' 'No']
Unique values of I have sensor lighting or timed lighting in my house for when I’m not at home
[nan 'Yes' 'No']
Unique values of My television and radio/stereo is timed to switch on and off when I’m not at home
[nan]
Unique values of I keep all my doors and windows locked when I’m at home or in my yard
[nan 'Yes' 'No']
Unique values of Any manholes or skylights are kept locked and/or bolted from the inside
[nan 'Yes' 'No']
Unique values of I have a dog
[nan 'Yes' 'No']
Unique values of Wallets, handbags, smartphones and jewellery stored safely out of sight
[nan 'Yes' 'No']
Unique values of Computers, televisions and other electronics not visible from outside
[nan 'Yes' 'No']
Unique values of Power tools kept out of sight or in securely-looked shed or garage
[nan 'Yes' 'No']
Unique values of Valuables photographed or videoed
[nan 'Yes' 'No']
Unique values of Serial numbers, makes and models of valuables recorded
[nan 'Yes' 'No']
Unique values of Valuables inscribed with a “V” plus driver’s license number
[nan 'Yes' 'No']
Unique values of Valuables kept in a secured, locked safe located out of sight.
[nan 'Yes' 'No']
Unique values of House number is clearly displayed
[nan 'Yes' 'No']
Unique values of House number is visible at night
[nan 'Yes' 'No']
Unique values of Security camera faces entry
[nan 'Security cameras in entry' 'Yes' 'No']
Unique values of Garden kept short and neat
[nan 'Yes' 'No']
Unique values of Front door and entry can be seen from street
[nan 'Yes' 'No']
Unique values of Motion sensor or timed lighting
[nan 'Yes' 'No']
Unique values of Neighbourhood Watch stickers visible
[nan 'Yes' 'No']
Unique values of What fences does your property have?
[nan 'Front fence, Side fence(s), Rear fence' 'Side fence(s), Rear fence'
 'Front fence, Rear fence' 'Front fence' 'Side fence(s)' 'Rear fence'
 'Front fence, Side fence(s)']
Unique values of Which of the following security measures do you have in place for your front fence and gate
[nan
 'Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings'
 'Fencing in good condition, Ladders are locked inside buildings'
 'Fencing in good condition, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins)'
 'Fencing in good condition, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings'
 'Fencing in good condition, Fencing not climbable'
 'Fencing not climbable'
 'Fencing in good condition, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings'
 'Fencing not climbable, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition'
 'Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, Fencing not climbable, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, No climbable obstacles placed adjacent (eg, garbage bins), Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, Fencing not climbable, Ladders are locked inside buildings'
 'Fencing in good condition, Fencing not climbable, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, No climbable obstacles placed adjacent (eg, garbage bins)'
 'Ladders are locked inside buildings'
 'Fencing in good condition, Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins)'
 'Fencing is in good condition, Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition'
 'Fencing is in good condition, Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Fencing is difficult to climb over, Gates have quality keyed locks and/or lockable bolts'
 'Bins and other climbable obstacles stored away from fences, in a secure area'
 'Fencing is in good condition, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings'
 'Fencing is in good condition, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Fencing is difficult to climb over, Ladders are locked inside buildings'
 'Fencing is in good condition, Fencing is difficult to climb over, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Ladders are locked inside buildings'
 'Fencing is in good condition, Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings'
 'Fencing is in good condition, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is difficult to climb over, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area'
 'Fencing is difficult to climb over, Ladders are locked inside buildings'
 'Fencing is difficult to climb over'
 'Fencing is in good condition, Bins and other climbable obstacles stored away from fences, in a secure area, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Fencing is difficult to climb over'
 'Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings'
 'Fencing is in good condition, Bins and other climbable obstacles stored away from fences, in a secure area'
 'Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area'
 'Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings'
 'Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Gates have quality keyed locks and/or lockable bolts'
 'Bins and other climbable obstacles stored away from fences, in a secure area, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is difficult to climb over, Gates have quality keyed locks and/or lockable bolts']
Unique values of Which of the following security measures do you have in place for your rear and side fences and gates.
[nan]
Unique values of Do you have any outdoor buildings such as sheds, a studio or granny flat?
[nan 'Yes' 'No']
Unique values of Which of these security measures do you have on your outdoor buildings
[nan 'Lockable door bolt' 'Building secured to ground, Quality keyed lock'
 'Building secured to ground, Lockable door bolt'
 'Building secured to ground, Solid core door and frame'
 'Building secured to ground, Quality keyed lock, Lockable door bolt'
 'Building secured to ground, Motion detector lighting'
 'Building secured to ground'
 'Building secured to ground, Solid core door and frame, Quality keyed lock'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Quality window lock'
 'Solid core door and frame, Quality window lock' 'Quality keyed lock'
 'Building secured to ground, Quality keyed lock, Lockable door bolt, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Lockable door bolt, Quality window lock'
 'Building secured to ground, Solid core door and frame, Lockable door bolt'
 'Solid core door and frame, Motion detector lighting'
 'Lockable door bolt, Motion detector lighting'
 'Building secured to ground, Quality keyed lock, Quality window lock'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Lockable door bolt'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Lockable door bolt, Quality window lock, Motion detector lighting'
 'Building secured to ground, Quality keyed lock, Motion detector lighting'
 'Motion detector lighting'
 'Building secured to ground, Quality keyed lock, Lockable door bolt, Quality window lock, Motion detector lighting'
 'Solid core door and frame, Lockable door bolt'
 'Building secured to ground, Quality keyed lock, Lockable door bolt, Quality window lock'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Lockable door bolt, Motion detector lighting'
 'Quality keyed lock, Lockable door bolt'
 'Quality keyed lock, Motion detector lighting'
 'Building secured to ground, Lockable door bolt, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Lockable door bolt, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Motion detector lighting'
 'Quality keyed lock, Quality window lock'
 'Solid core door and frame, Quality keyed lock, Quality window lock, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Quality window lock, Motion detector lighting'
 'Solid core door and frame, Quality keyed lock'
 'Building secured to ground, Solid core door and frame, Motion detector lighting'
 'Solid core door and frame'
 'Building secured to ground, Quality keyed lock, Quality window lock, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Lockable door bolt, Quality window lock'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Quality window lock, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Lockable door bolt, Quality window lock, Motion detector lighting'
 'Solid core door and frame, Quality keyed lock, Motion detector lighting'
 'Solid core door and frame, Lockable door bolt, Quality window lock'
 'Building secured to ground, Lockable door bolt, Quality window lock']
Unique values of Does your home have an enclosed garage?
[nan 'Yes' 'No']
Unique values of What security measures do you have in place for your garage
[nan
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Sensor lighting at entry'
 'All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use'
 'Door remote not stored in car, All garage doors are kept locked when not in use'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Windows have reinforced glass and blinds'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Main door has dedicated lock/bolt separate to electronic opener'
 'Sensor lighting at entry'
 'All garage doors are kept locked when not in use, Security camera at entry point'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Sensor lighting at entry, Security camera at entry point'
 'All garage doors are kept locked when not in use, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Door remote not stored in car, Sensor lighting at entry'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point'
 'Door remote not stored in car, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Security camera at entry point'
 'Door remote not stored in car, Service/entry door has deadbolt and heavy-duty strike plate'
 'Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Windows have reinforced glass and blinds'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car'
 'Main garage door kept locked when not in use'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times.'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times.'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Security camera at entry point'
 'Main garage door kept locked when not in use, Windows have reinforced glass and blinds'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry'
 'Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Sensor lighting at entry'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Security camera at entry point'
 'Access door to house kept locked at all times., Sensor lighting at entry'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Access door to house kept locked at all times.'
 'Door remote not stored in car, Access door to house kept locked at all times., Security camera at entry point'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times.'
 'Main garage door kept locked when not in use, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Sensor lighting at entry, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Access door to house kept locked at all times., Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point'
 'Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Sensor lighting at entry, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point'
 'Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Windows have reinforced glass and blinds'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point'
 'Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Windows have reinforced glass and blinds'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Door remote not stored in car, Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Windows have reinforced glass and blinds, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point'
 'Main garage door kept locked when not in use, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener']
In [6]:
#Replace NA
for col in df:
    print('\nAfter transformation')
    df[col] = df[col].fillna('No Response')
    print(df[col].unique())
    print('')
After transformation
['No Response' '3199' '3189' '3085' '3079' '3219' '3019' '3103' '3182'
 '3931' '3223' '3335' '3037' '3026' '3029' '3444' '3198' '3215' '3086'
 '3046' '3108' '3028' '3099' '3197' '3764' '3000' '3844' '66220' '2602'
 '6000' '3196' '3071' '3070' '3016' '3756' '3564' '3608' '3977' '3820'
 '3939' '3013' '3212' '3930' '3111' '3810' '3975' '3978' '3809' '3757'
 '3806' '3113' '3040' '2305' '2114' '3030' '3088' '3109' '3059' '3224'
 '3130' '3875' '3131' '3434' '2207' '3350' '3058' '3170' '3008' '3173'
 '3754' '3020' '3128' '3195' '2740' '19123' '3188' '3136' '3191' '3107'
 '820' '3336' '3074' '3915' '3358' '3148' '3840' '3105' '3204' '3149'
 '3158' '3174' '3031' '3083' '3976' '4814' '3804' '800' '3555' '3064'
 '3630' '3134' '3106' '3138' '3123' '6082' '3936' '3672' '3133' '3666'
 '3066' '3466' '3186' '3178' '3146' '3166' '3144' '3153' '3429' '6171'
 '3192' '3095' '3143' '3081' '3550' '3722' '3226' '3073' '3126' '3104'
 '3084' '3129' '3132' '3161' '3150' '3004' '3171' '3217' '3137' '3024'
 'mer' '3461' '3918' '3818' '2720' '3172' '3101' '3145' '3036' '3156'
 '2295' '3802' '3824' '110047' '3220' '3551' '3453' '3953' '3995' '3909'
 '3152' '3089' '3068' '3121' '3179' '3690' '3147' '3216' '3018' '3151'
 '3187' '3093' '3791' '3880' '5172' '3155' '3438' '3352' '3163' '3044'
 '3752' '3033' '3094' '3194' '3127' '3356' '3141' '3047' '5064' '3636'
 '3142' '3400' '3122' '3214' '3669' '3181' '3115' '4218' '3579' '3280'
 '3185' '3175' '3162' '3282' '3941' '3206' '3042' '3813' '3629' '3807'
 '3620' '3205' '3631' '3096' '3442' '3783' '3135' '3140' '3910' '3561'
 '3996' '3193' '3337' '3677' '3858' '3043' '3225' '3067' '3102' '3116'
 '3338' '3621' '3340' '3505' '3264' '3015' '3201' '4512' '3165' '3082'
 '3227' '3371' '3825' '3869' '3431' '3023' '3075' '3469' '3793' '3154'
 '3435' '3305' '2151' '3805' '3451' '3124' '3055' '2648' '3184' '3331'
 '3125' '3787' '3012' '3021' '2680' '3351' '3938' '3041' '3034' '3222'
 '3228' 'Thorne' '3926' '3038' '3750' '3850' '3087' '3032' '3078' '3060'
 '3954' '3011' '3437' '3052' '3401' '3498' '3355' '3114' '3803' '3056'
 '3051' '3523' '3276' '3842' '3200' 'Grivas' '3500' '3496' '3796' '3054'
 '3076' '3580' '3671' '3159' '3747' '3039' '3053' '3714' '3490' '6055'
 '3980' '4817' '4655' '3207' '4575' '3911' '3614' '3218' '3300' '3450'
 '3183' '3922' 'Rooney' '7310' '3084he' '3377' '3737' '3027' '3160' '4410'
 '3966' '7268' '7901' '3897' '3169' '3167' '7896']


After transformation
['No Response' 5.0 10.0 9.0 7.0 2.0 6.0 8.0 1.0 4.0 3.0]


After transformation
['No Response' 'House' 'Unit/Townhouse' 'Farm' 'Apartment']


After transformation
['No Response' 'Front door, Rear door, Side door(s)' 'Front door'
 'Front door, Rear door' 'Front door, Side door(s)' 'Side door(s)'
 'Rear door, Side door(s)' 'Rear door']


After transformation
['No Response' 'I know them very well and leave a spare key with them'
 'I know them to say hello and we talk occasionally, but that’s it'
 'I know them fairly well, we keep an eye on each other’s places'
 'I don’t know them']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Motion sensors/detector, Unmonitored security alarm'
 'Unmonitored security alarm'
 'Motion sensors/detector, Monitored security system'
 'Motion sensors/detector, Window or door sensors, Security cameras in entry'
 'Motion sensors/detector, Unmonitored security alarm, Window or door sensors, Security cameras in entry, Security footage stored safely'
 'Unmonitored security alarm, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector'
 'Security cameras in entry, Security footage stored safely'
 'Monitored security system'
 'Motion sensors/detector, Security cameras in entry'
 'Security cameras in entry'
 'Motion sensors/detector, Unmonitored security alarm, Security footage stored safely'
 'Motion sensors/detector, Unmonitored security alarm, Window or door sensors'
 'Motion sensors/detector, Security footage stored safely'
 'Monitored security system, Window or door sensors, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Monitored security system, Security cameras in entry'
 'Motion sensors/detector, Monitored security system, Unmonitored security alarm, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Unmonitored security alarm, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Unmonitored security alarm, Security cameras in entry'
 'Motion sensors/detector, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Monitored security system, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Monitored security system, Security footage stored safely'
 'Monitored security system, Security cameras in entry, Security footage stored safely'
 'Motion sensors/detector, Monitored security system, Window or door sensors'
 'Motion sensors/detector, Monitored security system, Window or door sensors, Security cameras in entry, Security footage stored safely'
 'Unmonitored security alarm, Window or door sensors'
 'Security footage stored safely'
 'Unmonitored security alarm, Security footage stored safely'
 'Monitored security system, Window or door sensors'
 'Monitored security system, Security footage stored safely'
 'Monitored security system, Security cameras in entry'
 'Unmonitored security alarm, Security cameras in entry'
 'Motion sensors/detector, Unmonitored security alarm, Window or door sensors, Security cameras in entry'
 'Motion sensors/detector, Window or door sensors'
 'Motion sensors/detector, Window or door sensors, Security cameras in entry, Security footage stored safely'
 'Window or door sensors'
 'Motion sensors/detector, Window or door sensors, Security footage stored safely']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Security cameras in entry' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Front fence, Side fence(s), Rear fence'
 'Side fence(s), Rear fence' 'Front fence, Rear fence' 'Front fence'
 'Side fence(s)' 'Rear fence' 'Front fence, Side fence(s)']


After transformation
['No Response'
 'Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings'
 'Fencing in good condition, Ladders are locked inside buildings'
 'Fencing in good condition, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins)'
 'Fencing in good condition, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings'
 'Fencing in good condition, Fencing not climbable'
 'Fencing not climbable'
 'Fencing in good condition, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins), Ladders are locked inside buildings'
 'Fencing not climbable, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition'
 'Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, Fencing not climbable, Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, No climbable obstacles placed adjacent (eg, garbage bins), Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, Fencing not climbable, Ladders are locked inside buildings'
 'Fencing in good condition, Fencing not climbable, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Gates have quality keyed locks and/or lockable bolts'
 'Fencing in good condition, No climbable obstacles placed adjacent (eg, garbage bins)'
 'Ladders are locked inside buildings'
 'Fencing in good condition, Fencing not climbable, No climbable obstacles placed adjacent (eg, garbage bins)'
 'Fencing is in good condition, Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition'
 'Fencing is in good condition, Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Fencing is difficult to climb over, Gates have quality keyed locks and/or lockable bolts'
 'Bins and other climbable obstacles stored away from fences, in a secure area'
 'Fencing is in good condition, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings'
 'Fencing is in good condition, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Fencing is difficult to climb over, Ladders are locked inside buildings'
 'Fencing is in good condition, Fencing is difficult to climb over, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Ladders are locked inside buildings'
 'Fencing is in good condition, Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings'
 'Fencing is in good condition, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is difficult to climb over, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area'
 'Fencing is difficult to climb over, Ladders are locked inside buildings'
 'Fencing is difficult to climb over'
 'Fencing is in good condition, Bins and other climbable obstacles stored away from fences, in a secure area, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is in good condition, Fencing is difficult to climb over'
 'Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings'
 'Fencing is in good condition, Bins and other climbable obstacles stored away from fences, in a secure area'
 'Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area'
 'Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Ladders are locked inside buildings'
 'Fencing is difficult to climb over, Bins and other climbable obstacles stored away from fences, in a secure area, Gates have quality keyed locks and/or lockable bolts'
 'Bins and other climbable obstacles stored away from fences, in a secure area, Gates have quality keyed locks and/or lockable bolts'
 'Fencing is difficult to climb over, Gates have quality keyed locks and/or lockable bolts']


After transformation
['No Response']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response' 'Lockable door bolt'
 'Building secured to ground, Quality keyed lock'
 'Building secured to ground, Lockable door bolt'
 'Building secured to ground, Solid core door and frame'
 'Building secured to ground, Quality keyed lock, Lockable door bolt'
 'Building secured to ground, Motion detector lighting'
 'Building secured to ground'
 'Building secured to ground, Solid core door and frame, Quality keyed lock'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Quality window lock'
 'Solid core door and frame, Quality window lock' 'Quality keyed lock'
 'Building secured to ground, Quality keyed lock, Lockable door bolt, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Lockable door bolt, Quality window lock'
 'Building secured to ground, Solid core door and frame, Lockable door bolt'
 'Solid core door and frame, Motion detector lighting'
 'Lockable door bolt, Motion detector lighting'
 'Building secured to ground, Quality keyed lock, Quality window lock'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Lockable door bolt'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Lockable door bolt, Quality window lock, Motion detector lighting'
 'Building secured to ground, Quality keyed lock, Motion detector lighting'
 'Motion detector lighting'
 'Building secured to ground, Quality keyed lock, Lockable door bolt, Quality window lock, Motion detector lighting'
 'Solid core door and frame, Lockable door bolt'
 'Building secured to ground, Quality keyed lock, Lockable door bolt, Quality window lock'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Lockable door bolt, Motion detector lighting'
 'Quality keyed lock, Lockable door bolt'
 'Quality keyed lock, Motion detector lighting'
 'Building secured to ground, Lockable door bolt, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Lockable door bolt, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Motion detector lighting'
 'Quality keyed lock, Quality window lock'
 'Solid core door and frame, Quality keyed lock, Quality window lock, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Quality window lock, Motion detector lighting'
 'Solid core door and frame, Quality keyed lock'
 'Building secured to ground, Solid core door and frame, Motion detector lighting'
 'Solid core door and frame'
 'Building secured to ground, Quality keyed lock, Quality window lock, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Lockable door bolt, Quality window lock'
 'Building secured to ground, Solid core door and frame, Quality keyed lock, Quality window lock, Motion detector lighting'
 'Building secured to ground, Solid core door and frame, Lockable door bolt, Quality window lock, Motion detector lighting'
 'Solid core door and frame, Quality keyed lock, Motion detector lighting'
 'Solid core door and frame, Lockable door bolt, Quality window lock'
 'Building secured to ground, Lockable door bolt, Quality window lock']


After transformation
['No Response' 'Yes' 'No']


After transformation
['No Response'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Sensor lighting at entry'
 'All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use'
 'Door remote not stored in car, All garage doors are kept locked when not in use'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Windows have reinforced glass and blinds'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Main door has dedicated lock/bolt separate to electronic opener'
 'Sensor lighting at entry'
 'All garage doors are kept locked when not in use, Security camera at entry point'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Sensor lighting at entry, Security camera at entry point'
 'All garage doors are kept locked when not in use, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Door remote not stored in car, Sensor lighting at entry'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point'
 'Door remote not stored in car, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Security camera at entry point'
 'Door remote not stored in car, Service/entry door has deadbolt and heavy-duty strike plate'
 'Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'All garage doors are kept locked when not in use, Windows have reinforced glass and blinds'
 'All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, All garage doors are kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car'
 'Main garage door kept locked when not in use'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times.'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times.'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Security camera at entry point'
 'Main garage door kept locked when not in use, Windows have reinforced glass and blinds'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry'
 'Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Sensor lighting at entry'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Security camera at entry point'
 'Access door to house kept locked at all times., Sensor lighting at entry'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Access door to house kept locked at all times.'
 'Door remote not stored in car, Access door to house kept locked at all times., Security camera at entry point'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times.'
 'Main garage door kept locked when not in use, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Sensor lighting at entry, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Access door to house kept locked at all times., Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point'
 'Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Sensor lighting at entry, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point'
 'Sensor lighting at entry, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Windows have reinforced glass and blinds'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point'
 'Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Main garage door kept locked when not in use, Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Service/entry door has deadbolt and heavy-duty strike plate'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Windows have reinforced glass and blinds'
 'Main garage door kept locked when not in use, Access door to house kept locked at all times., Service/entry door has deadbolt and heavy-duty strike plate, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Main garage door kept locked when not in use, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Main garage door kept locked when not in use, Sensor lighting at entry, Windows have reinforced glass and blinds, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Sensor lighting at entry, Service/entry door has deadbolt and heavy-duty strike plate, Security camera at entry point'
 'Door remote not stored in car, Sensor lighting at entry, Windows have reinforced glass and blinds'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Door remote not stored in car, Sensor lighting at entry, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener'
 'Access door to house kept locked at all times., Windows have reinforced glass and blinds, Security camera at entry point'
 'Door remote not stored in car, Main garage door kept locked when not in use, Access door to house kept locked at all times., Sensor lighting at entry, Windows have reinforced glass and blinds, Security camera at entry point'
 'Main garage door kept locked when not in use, Security camera at entry point, Main door has dedicated lock/bolt separate to electronic opener']

In [7]:
print('\nAfter transformation')
df['Postcode'] = df['Postcode'].replace({'Rooney': 0, 'mer': 0,'No Response': 0, 'Thorne':0, 'Grivas':0,'3084he': 3084})
print(df['Postcode'].unique())
After transformation
[0 '3199' '3189' '3085' '3079' '3219' '3019' '3103' '3182' '3931' '3223'
 '3335' '3037' '3026' '3029' '3444' '3198' '3215' '3086' '3046' '3108'
 '3028' '3099' '3197' '3764' '3000' '3844' '66220' '2602' '6000' '3196'
 '3071' '3070' '3016' '3756' '3564' '3608' '3977' '3820' '3939' '3013'
 '3212' '3930' '3111' '3810' '3975' '3978' '3809' '3757' '3806' '3113'
 '3040' '2305' '2114' '3030' '3088' '3109' '3059' '3224' '3130' '3875'
 '3131' '3434' '2207' '3350' '3058' '3170' '3008' '3173' '3754' '3020'
 '3128' '3195' '2740' '19123' '3188' '3136' '3191' '3107' '820' '3336'
 '3074' '3915' '3358' '3148' '3840' '3105' '3204' '3149' '3158' '3174'
 '3031' '3083' '3976' '4814' '3804' '800' '3555' '3064' '3630' '3134'
 '3106' '3138' '3123' '6082' '3936' '3672' '3133' '3666' '3066' '3466'
 '3186' '3178' '3146' '3166' '3144' '3153' '3429' '6171' '3192' '3095'
 '3143' '3081' '3550' '3722' '3226' '3073' '3126' '3104' '3084' '3129'
 '3132' '3161' '3150' '3004' '3171' '3217' '3137' '3024' '3461' '3918'
 '3818' '2720' '3172' '3101' '3145' '3036' '3156' '2295' '3802' '3824'
 '110047' '3220' '3551' '3453' '3953' '3995' '3909' '3152' '3089' '3068'
 '3121' '3179' '3690' '3147' '3216' '3018' '3151' '3187' '3093' '3791'
 '3880' '5172' '3155' '3438' '3352' '3163' '3044' '3752' '3033' '3094'
 '3194' '3127' '3356' '3141' '3047' '5064' '3636' '3142' '3400' '3122'
 '3214' '3669' '3181' '3115' '4218' '3579' '3280' '3185' '3175' '3162'
 '3282' '3941' '3206' '3042' '3813' '3629' '3807' '3620' '3205' '3631'
 '3096' '3442' '3783' '3135' '3140' '3910' '3561' '3996' '3193' '3337'
 '3677' '3858' '3043' '3225' '3067' '3102' '3116' '3338' '3621' '3340'
 '3505' '3264' '3015' '3201' '4512' '3165' '3082' '3227' '3371' '3825'
 '3869' '3431' '3023' '3075' '3469' '3793' '3154' '3435' '3305' '2151'
 '3805' '3451' '3124' '3055' '2648' '3184' '3331' '3125' '3787' '3012'
 '3021' '2680' '3351' '3938' '3041' '3034' '3222' '3228' '3926' '3038'
 '3750' '3850' '3087' '3032' '3078' '3060' '3954' '3011' '3437' '3052'
 '3401' '3498' '3355' '3114' '3803' '3056' '3051' '3523' '3276' '3842'
 '3200' '3500' '3496' '3796' '3054' '3076' '3580' '3671' '3159' '3747'
 '3039' '3053' '3714' '3490' '6055' '3980' '4817' '4655' '3207' '4575'
 '3911' '3614' '3218' '3300' '3450' '3183' '3922' '7310' 3084 '3377'
 '3737' '3027' '3160' '4410' '3966' '7268' '7901' '3897' '3169' '3167'
 '7896']
In [8]:
#Convert to numeric
df['Postcode'] = pd.to_numeric(df['Postcode'],errors='coerce')
In [9]:
#load suburb, lat long data
df1 = pd.read_csv("location.csv",sep =',')
In [10]:
df1.head()
Out[10]:
Postcode suburb state lat lon
0 3000 MELBOURNE VIC -37.814563 144.970267
1 3001 MELBOURNE VIC -38.365017 144.765920
2 3002 EAST MELBOURNE VIC -37.816640 144.987811
3 3003 WEST MELBOURNE VIC -37.806255 144.941123
4 3004 MELBOURNE VIC -37.837324 144.976335
In [11]:
#Merge using postcode as key
u = df.assign(cnt=df.groupby('Postcode').cumcount())
v = df1.assign(cnt=df1.groupby('Postcode').cumcount())
In [12]:
v = v.drop_duplicates(subset='Postcode', keep='first')
In [13]:
print(v.shape)
v.head()
(746, 6)
Out[13]:
Postcode suburb state lat lon cnt
0 3000 MELBOURNE VIC -37.814563 144.970267 0
1 3001 MELBOURNE VIC -38.365017 144.765920 0
2 3002 EAST MELBOURNE VIC -37.816640 144.987811 0
3 3003 WEST MELBOURNE VIC -37.806255 144.941123 0
4 3004 MELBOURNE VIC -37.837324 144.976335 0
In [14]:
df_new = u.merge(v, on=['Postcode'], how='left')
print(df_new.shape)
df_new.head()
(1126, 44)
Out[14]:
Postcode How safe do you feel when you are in your home? What type of home do you live in? Which of the following external doors does your home have? How well do you know your neighbours? Keys stored out of sight in a secret spot. Spare keys not hidden in obvious places outside the home Keys not kept in locks when not at home Spare key kept with trusted friend, relative or neighbour Does your home have any security systems? ... Do you have any outdoor buildings such as sheds, a studio or granny flat? Which of these security measures do you have on your outdoor buildings Does your home have an enclosed garage? What security measures do you have in place for your garage cnt_x suburb state lat lon cnt_y
0 0 No Response No Response No Response No Response No Response No Response No Response No Response No Response ... No Response No Response No Response No Response 0 NaN NaN NaN NaN NaN
1 3199 No Response House No Response I know them very well and leave a spare key wi... No Response No Response No Response No Response No Response ... No Response No Response No Response No Response 0 FRANKSTON VIC -38.145001 145.122477 0.0
2 3199 No Response House No Response I know them very well and leave a spare key wi... Yes Yes Yes No Response Yes ... No Response No Response No Response No Response 1 FRANKSTON VIC -38.145001 145.122477 0.0
3 3189 No Response House No Response I know them to say hello and we talk occasiona... Yes Yes Yes No Response Yes ... No Response No Response No Response No Response 0 MOORABBIN VIC -37.934352 145.036735 0.0
4 3085 No Response House No Response I know them fairly well, we keep an eye on eac... Yes Yes Yes No Response Yes ... No Response No Response No Response No Response 0 MACLEOD VIC -37.726038 145.068457 0.0

5 rows × 44 columns

In [15]:
df_new.isnull().sum()
Out[15]:
Postcode                                                                                                   0
How safe do you feel when you are in your home?                                                            0
What type of home do you live in?                                                                          0
Which of the following external doors does your home have?                                                 0
How well do you know your neighbours?                                                                      0
Keys stored out of sight in a secret spot.                                                                 0
Spare keys not hidden in obvious places outside the home                                                   0
Keys not kept in locks when not at home                                                                    0
Spare key kept with trusted friend, relative or neighbour                                                  0
Does your home have any security systems?                                                                  0
Which of the follow systems do you have in place?                                                          0
I keep a phone in my bedroom at night                                                                      0
I have sensor lighting or timed lighting in my house for when I’m not at home                              0
My television and radio/stereo is timed to switch on and off when I’m not at home                          0
I keep all my doors and windows locked when I’m at home or in my yard                                      0
Any manholes or skylights are kept locked and/or bolted from the inside                                    0
I have a dog                                                                                               0
Wallets, handbags, smartphones and jewellery stored safely out of sight                                    0
Computers, televisions and other electronics not visible from outside                                      0
Power tools kept out of sight or in securely-looked shed or garage                                         0
Valuables photographed or videoed                                                                          0
Serial numbers, makes and models of valuables recorded                                                     0
Valuables inscribed with a “V” plus driver’s license number                                                0
Valuables kept in a secured, locked safe located out of sight.                                             0
House number is clearly displayed                                                                          0
House number is visible at night                                                                           0
Security camera faces entry                                                                                0
Garden kept short and neat                                                                                 0
Front door and entry can be seen from street                                                               0
Motion sensor or timed lighting                                                                            0
Neighbourhood Watch stickers visible                                                                       0
What fences does your property have?                                                                       0
Which of the following security measures do you have in place for your front fence and gate                0
Which of the following security measures do you have in place for your rear and side fences and gates.     0
Do you have any outdoor buildings such as sheds, a studio or granny flat?                                  0
Which of these security measures do you have on your outdoor buildings                                     0
Does your home have an enclosed garage?                                                                    0
What security measures do you have in place for your garage                                                0
cnt_x                                                                                                      0
suburb                                                                                                    46
state                                                                                                     46
lat                                                                                                       46
lon                                                                                                       46
cnt_y                                                                                                     46
dtype: int64
In [16]:
#!pip install descartes

Load shape file of Victoria

In [17]:
nb = 'VIC_LOCALITY_POLYGON_shp.shp'
regions = gpd.read_file(nb)
regions.head()
Out[17]:
LC_PLY_PID DT_CREATE DT_RETIRE LOC_PID VIC_LOCALI VIC_LOCA_1 VIC_LOCA_2 VIC_LOCA_3 VIC_LOCA_4 VIC_LOCA_5 VIC_LOCA_6 VIC_LOCA_7 geometry
0 6670 2011-08-31 None VIC2615 2012-04-27 None UNDERBOOL None None G None 2 POLYGON ((141.74552399 -35.07228701, 141.74552...
1 6671 2011-08-31 None VIC1986 2012-04-27 None NURRAN None None G None 2 POLYGON ((148.668767 -37.39571245, 148.6687620...
2 6672 2011-08-31 None VIC2862 2012-04-27 None WOORNDOO None None G None 2 POLYGON ((142.92287999 -37.97885997, 142.90449...
3 6673 2011-08-31 None VIC734 2018-08-03 None DEPTFORD None None G None 2 POLYGON ((147.82335712 -37.66000897, 147.82312...
4 6674 2011-08-31 None VIC2900 2012-04-27 None YANAC None None G None 2 POLYGON ((141.279783 -35.99858911, 141.2798853...
In [18]:
regions.rename(columns={'VIC_LOCA_2': 'suburb'}, inplace=True)
In [19]:
regions.head()
Out[19]:
LC_PLY_PID DT_CREATE DT_RETIRE LOC_PID VIC_LOCALI VIC_LOCA_1 suburb VIC_LOCA_3 VIC_LOCA_4 VIC_LOCA_5 VIC_LOCA_6 VIC_LOCA_7 geometry
0 6670 2011-08-31 None VIC2615 2012-04-27 None UNDERBOOL None None G None 2 POLYGON ((141.74552399 -35.07228701, 141.74552...
1 6671 2011-08-31 None VIC1986 2012-04-27 None NURRAN None None G None 2 POLYGON ((148.668767 -37.39571245, 148.6687620...
2 6672 2011-08-31 None VIC2862 2012-04-27 None WOORNDOO None None G None 2 POLYGON ((142.92287999 -37.97885997, 142.90449...
3 6673 2011-08-31 None VIC734 2018-08-03 None DEPTFORD None None G None 2 POLYGON ((147.82335712 -37.66000897, 147.82312...
4 6674 2011-08-31 None VIC2900 2012-04-27 None YANAC None None G None 2 POLYGON ((141.279783 -35.99858911, 141.2798853...
In [20]:
regions.shape
Out[20]:
(2973, 13)
In [21]:
#Load Victoria map
regions.plot(figsize=(40,20))
plt.show()
In [22]:
suburb = df_new.loc[:,'suburb']
rating = df_new.loc[:,'How safe do you feel when you are in your home?']
suburb = pd.DataFrame({'suburb': suburb,'rating':rating})
suburb['suburb'] = suburb['suburb'].str.lower()
regions['suburb'] =regions['suburb'].str.lower()
In [23]:
# Join the dataset with the available mapping files.
# We will fill in the neighbourhoods which were not present in the dataset with 0.
# this way we will still see the neighbourhood in the map, but no housing will be shown on it.
merged = regions.set_index('suburb').join(suburb.set_index('suburb'))
merged = merged.reset_index()
merged = merged.fillna(0)
merged[['suburb', 'geometry', 'rating']].head()
Out[23]:
suburb geometry rating
0 abbeyard POLYGON ((146.6725295 -36.99902764, 146.672528... 6
1 abbotsford POLYGON ((144.99137102 -37.809605, 144.992539 ... 8
2 aberfeldie POLYGON ((144.89829839 -37.76465028, 144.89789... 8
3 aberfeldie POLYGON ((144.89829839 -37.76465028, 144.89789... 8
4 aberfeldie POLYGON ((144.89829839 -37.76465028, 144.89789... 6
In [24]:
merged['rating'] = pd.to_numeric(merged['rating'],errors='coerce')

Overall safety ratings across Victoria

In [25]:
fig, ax = plt.subplots(1, figsize=(40, 20))
ax.axis('off')
ax.set_title('Heat Map of Safety Ratings in Victoria, Australia', fontdict={'fontsize': '40', 'fontweight' : '3'})

color = 'YlGn'
vmin, vmax = 0, 10
sm = plt.cm.ScalarMappable(cmap=color, norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []
cbar = fig.colorbar(sm)
cbar.ax.tick_params(labelsize=20)

# actually plot the map
# we will only annotate the plot for neighbourhoods with more than 50 houses sold
merged.plot('rating', cmap=color, linewidth=0.8, ax=ax, edgecolor='0.8', figsize=(40,20))
for idx, row in merged.iterrows():
    if(row['rating'] > 50):
        plt.annotate(text=row['suburb'], xy=(row['geometry'], row['geometry']),
                 horizontalalignment='center', fontsize='large', color='black', wrap=True)
plt.show()
fig.savefig('plot1.pdf')

Safest suburbs with safety rating of 10

In [26]:
merged_copy = merged.copy()
In [27]:
print('\nAfter transformation')
merged_copy['rating'] = merged_copy['rating'].replace({1.0: 0, 2.0:0, 3.0:0,4.0:0,5.0:0,6.0:0, 7.0:0, 8.0:0,9.0:0})
print(merged_copy['rating'].unique())
print('')
After transformation
[ 0. 10. nan]

In [28]:
merged.shape
Out[28]:
(3677, 14)
In [29]:
fig, ax = plt.subplots(1, figsize=(40, 20))
ax.axis('off')
ax.set_title('Heat Map of Highest Safety Rating of 10 in Victoria, Australia', fontdict={'fontsize': '40', 'fontweight' : '3'})

color = 'YlGn'
vmin, vmax = 0, 10
sm = plt.cm.ScalarMappable(cmap=color, norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []
cbar = fig.colorbar(sm)
cbar.ax.tick_params(labelsize=20)

# actually plot the map
# we will only annotate the plot for neighbourhoods with more than 50 houses sold
merged.plot('rating', cmap=color, linewidth=0.8, ax=ax, edgecolor='0.8', figsize=(40,20))
for idx, row in merged.iterrows():
    if(row['rating'] > 50):
        plt.annotate(text=row['suburb'], xy=(row['geometry'], row['geometry']),
                 horizontalalignment='center', fontsize='large', color='black', wrap=True)
plt.show()
fig.savefig('plot2.pdf')

Moderately safe suburbs with safety rating between 9 to 7

In [30]:
merged_copy2 = merged.copy()
In [31]:
print('\nAfter transformation')
merged_copy2['rating'] = merged_copy2['rating'].replace({1.0: 0, 2.0:0, 3.0:0,4.0:0,5.0:0,6.0:0, 10.0:0})
print(merged_copy2['rating'].unique())
print('')
After transformation
[ 0.  8.  9.  7. nan]

In [32]:
fig, ax = plt.subplots(1, figsize=(40, 20))
ax.axis('off')
ax.set_title('Heat Map of Safety Ratings between 9 to 7 in Victoria, Australia', fontdict={'fontsize': '40', 'fontweight' : '3'})

color = 'YlGn'
vmin, vmax = 0, 10
sm = plt.cm.ScalarMappable(cmap=color, norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []
cbar = fig.colorbar(sm)
cbar.ax.tick_params(labelsize=20)

# actually plot the map
# we will only annotate the plot for neighbourhoods with more than 50 houses sold
merged.plot('rating', cmap=color, linewidth=0.8, ax=ax, edgecolor='0.8', figsize=(40,20))
for idx, row in merged.iterrows():
    if(row['rating'] > 50):
        plt.annotate(text=row['suburb'], xy=(row['geometry'], row['geometry']),
                 horizontalalignment='center', fontsize='large', color='black', wrap=True)
plt.show()
fig.savefig('plot2.pdf')

Unsafe/least safe suburbs with safety rating between 6 to 1

In [33]:
merged_copy3 = merged.copy()
In [34]:
print('\nAfter transformation')
merged_copy3['rating'] = merged_copy3['rating'].replace({1.0: 0, 2.0:0, 3.0:0,4.0:0,5.0:0,6.0:0, 10.0:0})
print(merged_copy3['rating'].unique())
print('')
After transformation
[ 0.  8.  9.  7. nan]

In [35]:
fig, ax = plt.subplots(1, figsize=(40, 20))
ax.axis('off')
ax.set_title('Heat Map of Lowest Safety Ratings between 6 to 1 in Victoria, Australia', fontdict={'fontsize': '40', 'fontweight' : '3'})

color = 'Oranges'
vmin, vmax = 0, 6
sm = plt.cm.ScalarMappable(cmap=color, norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []
cbar = fig.colorbar(sm)
cbar.ax.tick_params(labelsize=20)

# actually plot the map
# we will only annotate the plot for neighbourhoods with more than 50 houses sold
merged.plot('rating', cmap=color, linewidth=0.8, ax=ax, edgecolor='0.8', figsize=(40,20))
for idx, row in merged.iterrows():
    if(row['rating'] > 50):
        plt.annotate(text=row['suburb'], xy=(row['geometry'], row['geometry']),
                 horizontalalignment='center', fontsize='large', color='black', wrap=True)
plt.show()

Overall safety ratings

In [36]:
suburb = df_new.loc[:,'suburb']
suburb.head()
Out[36]:
0          NaN
1    FRANKSTON
2    FRANKSTON
3    MOORABBIN
4      MACLEOD
Name: suburb, dtype: object
In [37]:
rating = df_new.loc[:,'How safe do you feel when you are in your home?']
rating.head()
Out[37]:
0    No Response
1    No Response
2    No Response
3    No Response
4    No Response
Name: How safe do you feel when you are in your home?, dtype: object
In [38]:
postcode = df_new.loc[:,'Postcode']
postcode.head()
Out[38]:
0       0
1    3199
2    3199
3    3189
4    3085
Name: Postcode, dtype: int64
In [39]:
suburb = pd.DataFrame({'suburb': suburb,'rating':rating, 'postcode': postcode})
suburb.head()
Out[39]:
suburb rating postcode
0 NaN No Response 0
1 FRANKSTON No Response 3199
2 FRANKSTON No Response 3199
3 MOORABBIN No Response 3189
4 MACLEOD No Response 3085
In [40]:
suburb['suburb'] = suburb['suburb'].str.lower()
In [41]:
regions['suburb'] =regions['suburb'].str.lower()
In [42]:
print('\nAfter transformation')
suburb['rating'] = suburb['rating'].replace({'No Response': 0})
print(suburb['rating'].unique())
print('')
After transformation
[ 0.  5. 10.  9.  7.  2.  6.  8.  1.  4.  3.]

In [43]:
print(suburb.shape)
print(regions.shape)
(1126, 3)
(2973, 13)
In [44]:
a = suburb.assign(cnt=suburb.groupby('suburb').cumcount())
b = regions.assign(cnt=regions.groupby('suburb').cumcount())
In [45]:
merged1 =a.merge(b, on=['suburb','cnt'], how='left')
print(merged1.shape)
merged1.head(2)
(1126, 16)
Out[45]:
suburb rating postcode cnt LC_PLY_PID DT_CREATE DT_RETIRE LOC_PID VIC_LOCALI VIC_LOCA_1 VIC_LOCA_3 VIC_LOCA_4 VIC_LOCA_5 VIC_LOCA_6 VIC_LOCA_7 geometry
0 NaN 0.0 0 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN None
1 frankston 0.0 3199 0 10715 2017-09-07 None VIC939 2017-11-01 None None None G None 2 POLYGON ((145.17297206 -38.1465126, 145.172811...
In [46]:
#Drop no postcode or wrong postcodes
merged1.dropna(subset=['suburb'], inplace=True)
print(merged1.shape)
(1080, 16)
In [47]:
merged1['rating'].value_counts().sort_index()
Out[47]:
0.0      10
1.0       5
2.0       5
3.0       3
4.0       6
5.0      19
6.0     176
7.0      90
8.0     269
9.0     306
10.0    191
Name: rating, dtype: int64
In [48]:
df_piechart = merged1['rating'].value_counts().sort_index()
In [49]:
import matplotlib.pyplot as plt

def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = df_piechart.index
sizes = df_piechart.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.0, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Percentage of Safety Ratings (in %)")
Out[49]:
Text(0.5, 1.0, 'Percentage of Safety Ratings (in %)')
In [50]:
import numpy as np
fig, ax1 = plt.subplots()

#Plot 1
#Treatment feature
df_treatment = merged1['rating'].value_counts().sort_index()
objects = df_treatment.index
y_pos = np.arange(len(objects))
performance = df_treatment.values


ax1.bar(y_pos, performance, align='center', alpha=0.7, color='G')
ax1.set_xticks(y_pos)
ax1.set_xticklabels(df_treatment.index)
ax1.set_ylabel('Count')
ax1.set_xlabel('Safety Ratings')
ax1.set_title('Total count of Safety Ratings')
ax1.set_facecolor('white')
ax1.grid(color='#95a5a6', linewidth=.8, axis='y', alpha=0.3)

for p in ax1.patches:
    height = p.get_height()
    ax1.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha="center", fontsize=9)
    
plt.show()

Safest suburbs with safety rating of 10

In [51]:
merged1_copy = merged1.copy()
In [52]:
len(merged1_copy['suburb'].unique())
Out[52]:
292
In [53]:
merged1_copy.shape
Out[53]:
(1080, 16)
In [54]:
#Filter 10 safety rating
safe_subs = merged1_copy[(merged1_copy['rating'] == 10)]

print(safe_subs.shape)
safe_subs.head()
(191, 16)
Out[54]:
suburb rating postcode cnt LC_PLY_PID DT_CREATE DT_RETIRE LOC_PID VIC_LOCALI VIC_LOCA_1 VIC_LOCA_3 VIC_LOCA_4 VIC_LOCA_5 VIC_LOCA_6 VIC_LOCA_7 geometry
12 indented head 10.0 3223 0 10002 2013-11-26 None VIC1221 2012-04-27 None None None G None 2 POLYGON ((144.7165235 -38.14398648, 144.716818...
14 delahey 10.0 3037 0 10181 2015-12-04 None VIC727 2016-01-25 None None None G None 2 POLYGON ((144.764359894 -37.72431483, 144.7643...
29 blackwarry 10.0 3844 0 10718 2017-09-07 None VIC256 2017-11-01 None None None G None 2 POLYGON ((146.65275504 -38.43310502, 146.65125...
38 chintin 10.0 3756 0 7489 2011-08-31 None VIC553 2012-04-27 None None None G None 2 POLYGON ((144.81842252 -37.42669756, 144.81815...
41 campaspe west 10.0 3564 1 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN None
In [55]:
len(safe_subs['suburb'].unique())
Out[55]:
127
In [56]:
safe_subs[['suburb', 'rating', 'postcode']]
Out[56]:
suburb rating postcode
12 indented head 10.0 3223
14 delahey 10.0 3037
29 blackwarry 10.0 3844
38 chintin 10.0 3756
41 campaspe west 10.0 3564
42 bailieston 10.0 3608
48 bona vista 10.0 3820
53 yarraville 10.0 3013
76 doncaster east 10.0 3109
80 doncaster east 10.0 3109
124 chadstone 10.0 3148
128 bulleen 10.0 3105
134 noble park 10.0 3174
142 bundoora 10.0 3083
148 craigieburn 10.0 3064
149 donvale 10.0 3111
167 cocoroc 10.0 3030
185 brighton 10.0 3186
196 cheltenham 10.0 3192
205 hoppers crossing 10.0 3029
209 mooroolbark 10.0 3138
212 mitcham 10.0 3132
216 keysborough 10.0 3173
220 melbourne 10.0 3004
224 kilsyth 10.0 3137
231 bentleigh 10.0 3204
240 sunbury 10.0 3429
252 sunbury 10.0 3429
253 indented head 10.0 3223
258 childers 10.0 3824
... ... ... ...
952 burnley 10.0 3121
953 thornbury 10.0 3071
957 ocean grove 10.0 3226
959 castlemaine 10.0 3450
960 mount waverley 10.0 3149
965 leopold 10.0 3224
967 ocean grove 10.0 3226
972 ivanhoe 10.0 3079
974 bentleigh 10.0 3204
977 bentleigh 10.0 3204
979 dawson 10.0 3858
982 hampton park 10.0 3976
994 pakenham 10.0 3810
1004 arthurs seat 10.0 3936
1011 thornbury 10.0 3071
1013 banyule 10.0 3084
1018 cotham 10.0 3101
1024 indented head 10.0 3223
1031 bentleigh 10.0 3204
1040 bareena 10.0 3220
1041 beaconsfield 10.0 3807
1053 altona meadows 10.0 3028
1054 caulfield east 10.0 3145
1062 fountain gate 10.0 3805
1065 bayswater 10.0 3153
1066 pakenham 10.0 3810
1078 oakleigh south 10.0 3167
1085 sunbury 10.0 3429
1116 churchill 10.0 3842
1124 indented head 10.0 3223

191 rows × 3 columns

In [57]:
slide2 = safe_subs[['suburb', 'rating', 'postcode']].sort_values(by = 'suburb', ascending = True)
In [58]:
slide2 = slide2.drop_duplicates(subset='suburb', keep='first')
slide2_2 =slide2.iloc[34:68]
slide2_3 =slide2.iloc[68:127]
In [59]:
import six
def render_mpl_table(data, col_width=3.0, row_height=0.625, font_size=14,
                     header_color='lightseagreen', row_colors=['#f1f1f2', 'w'], edge_color='w',
                     bbox=[0, 0, 1, 1], header_columns=0,
                     ax=None, **kwargs):
    if ax is None:
        size = (np.array(data.shape[::-1]) + np.array([0, 1])) * np.array([col_width, row_height])
        fig, ax = plt.subplots(figsize=size)
        ax.axis('off')

    mpl_table = ax.table(cellText=data.values, bbox=bbox, colLabels=data.columns, **kwargs)

    mpl_table.auto_set_font_size(False)
    mpl_table.set_fontsize(font_size)

    for k, cell in six.iteritems(mpl_table._cells):
        cell.set_edgecolor(edge_color)
        if k[0] == 0 or k[1] < header_columns:
            cell.set_text_props(weight='bold', color='w')
            cell.set_facecolor(header_color)
        else:
            cell.set_facecolor(row_colors[k[0]%len(row_colors) ])
    return ax

render_mpl_table(slide2_3, header_columns=0, col_width=2.5)
Out[59]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fe2930a39e8>

Type of Home

In [60]:
slide3 = df_new.rename(columns={'How safe do you feel when you are in your home?': 'rating'})
In [61]:
print('\nAfter transformation')
slide3['rating'] = slide3 ['rating'].replace({'No Response': 0})
print(slide3['rating'].unique())
print('')
After transformation
[ 0.  5. 10.  9.  7.  2.  6.  8.  1.  4.  3.]

In [62]:
#Drop no postcode or wrong postcodes
slide3.dropna(subset=['suburb'], inplace=True)
print(slide3.shape)
(1080, 44)
In [63]:
#Filter 10 again
safe_subs3 = slide3[(slide3['rating'] == 10)]

print(safe_subs3.shape)
safe_subs3.head()
(191, 44)
Out[63]:
Postcode rating What type of home do you live in? Which of the following external doors does your home have? How well do you know your neighbours? Keys stored out of sight in a secret spot. Spare keys not hidden in obvious places outside the home Keys not kept in locks when not at home Spare key kept with trusted friend, relative or neighbour Does your home have any security systems? ... Do you have any outdoor buildings such as sheds, a studio or granny flat? Which of these security measures do you have on your outdoor buildings Does your home have an enclosed garage? What security measures do you have in place for your garage cnt_x suburb state lat lon cnt_y
12 3223 10.0 Farm Front door, Rear door, Side door(s) I know them very well and leave a spare key wi... No Response Yes Yes Yes No ... Yes Lockable door bolt Yes Door remote not stored in car, All garage door... 0 INDENTED HEAD VIC -38.139121 144.711239 0.0
14 3037 10.0 House Front door, Rear door, Side door(s) I know them fairly well, we keep an eye on eac... No Response Yes Yes Yes No ... Yes Building secured to ground, Quality keyed lock Yes All garage doors are kept locked when not in u... 0 DELAHEY VIC -37.715579 144.780474 0.0
29 3844 10.0 House Front door, Rear door I know them fairly well, we keep an eye on eac... No Response No No Yes No ... Yes Building secured to ground, Solid core door an... No No Response 0 BLACKWARRY VIC -38.406405 146.637984 0.0
38 3756 10.0 House Front door, Rear door, Side door(s) I know them fairly well, we keep an eye on eac... No No No Yes No ... No No Response Yes All garage doors are kept locked when not in u... 0 CHINTIN VIC -37.402359 144.802840 0.0
41 3564 10.0 House Front door, Side door(s) I know them fairly well, we keep an eye on eac... No No No Yes No ... No No Response Yes All garage doors are kept locked when not in u... 1 CAMPASPE WEST VIC -36.131154 144.728548 0.0

5 rows × 44 columns

In [64]:
safe_subs3['What type of home do you live in?'].value_counts().sort_values()
Out[64]:
Farm                5
Apartment           7
Unit/Townhouse     30
House             149
Name: What type of home do you live in?, dtype: int64
In [65]:
df_piechart2 = safe_subs3['What type of home do you live in?'].value_counts().sort_values()
In [66]:
df_piechart2 = safe_subs3['What type of home do you live in?'].value_counts().sort_values()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = df_piechart2.index
sizes = df_piechart2.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.85, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Type of Home (in %)")
Out[66]:
Text(0.5, 1.0, 'Type of Home (in %)')

Type of Doors

In [67]:
df_piechart3 = safe_subs3['Which of the following external doors does your home have?'].value_counts().sort_values()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = df_piechart3.index
sizes = df_piechart3.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.85, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Type of External Doors (in %)")
Out[67]:
Text(0.5, 1.0, 'Type of External Doors (in %)')

Type of Fences

In [68]:
df_piechart4 = safe_subs3['What fences does your property have?'].value_counts().sort_values()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = df_piechart4.index
sizes = df_piechart4.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.9, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Fences in the House(in %)")
Out[68]:
Text(0.5, 1.0, 'Fences in the House(in %)')

Security alarm at home

In [69]:
df_piechart4 = safe_subs3['Does your home have any security systems?'].value_counts().sort_index()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = df_piechart4.index
sizes = df_piechart4.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

theme = plt.get_cmap('RdYlGn')
#theme = plt.get_cmap('hot')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.85, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Does your home have any\n security systems? (in %)")
Out[69]:
Text(0.5, 1.0, 'Does your home have any\n security systems? (in %)')

House security measures

In [70]:
doorslocked = safe_subs3['I keep all my doors and windows locked when I’m at home or in my yard'].value_counts().sort_index()
doorslockedperc = np.true_divide(doorslocked.values, doorslocked.sum())*100
In [71]:
skylightlocked = safe_subs3['Any manholes or skylights are kept locked and/or bolted from the inside'].value_counts().sort_index()
In [72]:
computers =safe_subs3['Computers, televisions and other electronics not visible from outside'].value_counts().sort_index()
computersperc =np.true_divide(computers.values, computers.sum())*100
In [73]:
doorseen = safe_subs3['Front door and entry can be seen from street'].value_counts().sort_index()
doorseenperc =np.true_divide(doorseen.values, doorseen.sum())*100
In [74]:
housenum = safe_subs3['House number is clearly displayed'].value_counts().sort_index()
housenumperc =np.true_divide(housenum.values, housenum.sum())*100
In [75]:
housenumvis = safe_subs3['House number is visible at night'].value_counts().sort_index()
housenumvisperc =np.true_divide(housenumvis.values, housenumvis.sum())*100
In [76]:
gard = safe_subs3['Garden kept short and neat'].value_counts().sort_index()
gardperc =np.true_divide(gard.values, gard.sum())*100
In [77]:
camera= safe_subs3['Security camera faces entry'].value_counts().sort_index()
camperc = np.true_divide(camera.values, camera.sum())*100
In [78]:
dog= safe_subs3['I have a dog'].value_counts().sort_index()
dogperc = np.true_divide(dog.values, dog.sum())*100
In [79]:
value= safe_subs3['Valuables kept in a secured, locked safe located out of sight.'].value_counts().sort_index()
valueperc = np.true_divide(value.values, value.sum())*100
In [80]:
sensorlight= safe_subs3['I have sensor lighting or timed lighting in my house for when I’m not at home'].value_counts().sort_index()
sensorlightperc = np.true_divide(sensorlight.values, sensorlight.sum())*100
In [81]:
col_names = ["No",'Yes'] 
results = { 'Front door seen from street': doorseenperc,
           'House number is clearly displayed': housenumperc,
           'House number is visible at night': housenumvisperc,
           "Doors and windows locked": doorslockedperc,
           'Electronics out of sight': computersperc,
          'Garden kept short and neat': gardperc,
           'Sensor/timed lighting when not at home': sensorlightperc,
           'Security camera at home': camperc,
           'Dog at home': dogperc,
           'Valuables kept in a secured & locked safe': valueperc}
def survey(results, col_names):
    labels = list(results.keys())
    data = np.array(list(results.values()))
    data_cum = data.cumsum(axis=1)
    category_colors = plt.get_cmap('RdYlGn')(np.linspace(0.1, 0.90, data.shape[1]))
    fig, ax = plt.subplots(figsize=(9.9, 3.7))
    ax.invert_yaxis()
    ax.xaxis.set_visible(False)
    ax.set_xlim(0, np.sum(data, axis=1).max())
    for i, (colname, color) in enumerate(zip(col_names, category_colors)):
        widths = data[:, i]
        starts = data_cum[:, i] - widths
        ax.barh(labels, widths, left=starts, height=0.9, label=colname, color=color)
        xcenters = starts + widths / 2
        r, g, b, _ = color
        text_color = 'black' 
        for y, (x, c) in enumerate(zip(xcenters, widths)):
            ax.text(x, y, str(int(c)), ha='center', va='center',
                    color=text_color)
    ax.legend(ncol=len(col_names), bbox_to_anchor=(0.42, -0.15),
              loc='lower left', fontsize='small')
    return fig, ax
     
survey(results, col_names) 
plt.title("House security measures (in %)")

fig.tight_layout()
plt.show()
fig.savefig('plot5.pdf')

Moderately safe suburbs with safety rating between 9 to 7

In [82]:
#Filter 9 to 7 safety rating
msafe_subs = merged1_copy[merged1_copy.rating.isin([7,8,9])]

print(msafe_subs.shape)
(665, 16)
In [83]:
len(msafe_subs['suburb'].unique())
Out[83]:
247
In [84]:
table3 =msafe_subs[['suburb', 'rating', 'postcode']].sort_values(by = 'suburb', ascending = True)
In [85]:
table3 = table3.drop_duplicates(subset='suburb', keep='first')
table3_1 =table3.iloc[0:34]
table3_2 =table3.iloc[34:68]
table3_3 =table3.iloc[68:120]
In [86]:
import six
def render_mpl_table(data, col_width=3.0, row_height=0.625, font_size=14,
                     header_color='lightseagreen', row_colors=['#f1f1f2', 'w'], edge_color='w',
                     bbox=[0, 0, 1, 1], header_columns=0,
                     ax=None, **kwargs):
    if ax is None:
        size = (np.array(data.shape[::-1]) + np.array([0, 1])) * np.array([col_width, row_height])
        fig, ax = plt.subplots(figsize=size)
        ax.axis('off')

    mpl_table = ax.table(cellText=data.values, bbox=bbox, colLabels=data.columns, **kwargs)

    mpl_table.auto_set_font_size(False)
    mpl_table.set_fontsize(font_size)

    for k, cell in six.iteritems(mpl_table._cells):
        cell.set_edgecolor(edge_color)
        if k[0] == 0 or k[1] < header_columns:
            cell.set_text_props(weight='bold', color='w')
            cell.set_facecolor(header_color)
        else:
            cell.set_facecolor(row_colors[k[0]%len(row_colors) ])
    return ax

render_mpl_table(table3_3, header_columns=0, col_width=2.5)
Out[86]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fe2934ae2e8>
In [87]:
#Filter 7 to 9 safety rating
midsafe_subs =slide3[slide3.rating.isin([7,8,9])]

print(midsafe_subs.shape)
midsafe_subs.head()
(665, 44)
Out[87]:
Postcode rating What type of home do you live in? Which of the following external doors does your home have? How well do you know your neighbours? Keys stored out of sight in a secret spot. Spare keys not hidden in obvious places outside the home Keys not kept in locks when not at home Spare key kept with trusted friend, relative or neighbour Does your home have any security systems? ... Do you have any outdoor buildings such as sheds, a studio or granny flat? Which of these security measures do you have on your outdoor buildings Does your home have an enclosed garage? What security measures do you have in place for your garage cnt_x suburb state lat lon cnt_y
13 3335 9.0 House Front door, Rear door, Side door(s) I know them to say hello and we talk occasiona... No Response No No No Yes ... Yes No Response Yes All garage doors are kept locked when not in u... 0 PLUMPTON VIC -37.685840 144.685449 0.0
15 3026 9.0 House Front door, Rear door, Side door(s) I know them fairly well, we keep an eye on eac... No Response No Yes Yes Yes ... Yes Building secured to ground, Quality keyed lock Yes All garage doors are kept locked when not in u... 0 LAVERTON NORTH VIC -37.841653 144.795959 0.0
17 3444 7.0 Apartment Front door I know them to say hello and we talk occasiona... No Response Yes Yes Yes No ... Yes Building secured to ground, Solid core door an... No No Response 0 BARFOLD VIC -37.091978 144.506110 0.0
20 3086 7.0 House Front door, Rear door I know them to say hello and we talk occasiona... No Response No No Yes No ... No No Response No No Response 0 LA TROBE UNIVERSITY VIC -37.721328 145.047012 0.0
22 3108 9.0 House Front door, Rear door, Side door(s) I know them fairly well, we keep an eye on eac... No Response Yes Yes Yes Yes ... Yes Building secured to ground, Quality keyed lock... No No Response 0 DONCASTER VIC -37.783031 145.122517 0.0

5 rows × 44 columns

In [88]:
len(midsafe_subs['suburb'].unique())
Out[88]:
247

Type of Home

In [89]:
midsafe_subs['What type of home do you live in?'].value_counts().sort_values()
Out[89]:
Farm                8
Apartment           8
Unit/Townhouse    100
House             549
Name: What type of home do you live in?, dtype: int64
In [90]:
mdf_piechart1 = midsafe_subs['What type of home do you live in?'].value_counts().sort_values()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = mdf_piechart1.index
sizes = mdf_piechart1.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.85, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Type of Home (in %)")
Out[90]:
Text(0.5, 1.0, 'Type of Home (in %)')

Type of Doors

In [91]:
mdf_piechart2 = midsafe_subs['Which of the following external doors does your home have?'].value_counts().sort_values()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = mdf_piechart2.index
sizes = mdf_piechart2.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.9, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Type of External Doors (in %)")
Out[91]:
Text(0.5, 1.0, 'Type of External Doors (in %)')

Type of Fence

In [92]:
mdf_piechart3 = midsafe_subs['What fences does your property have?'].value_counts().sort_values()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = mdf_piechart3.index
sizes = mdf_piechart3.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.9, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Fences in the House(in %)")
Out[92]:
Text(0.5, 1.0, 'Fences in the House(in %)')

Security alarm at home

In [93]:
mdf_piechart4 = midsafe_subs['Security camera faces entry'].value_counts().sort_index()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = mdf_piechart4.index
sizes = mdf_piechart4.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.85, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Does your home have any\n security systems? (in %)")
Out[93]:
Text(0.5, 1.0, 'Does your home have any\n security systems? (in %)')

House security measures

In [94]:
doorslockedm = midsafe_subs['I keep all my doors and windows locked when I’m at home or in my yard'].value_counts().sort_index()
doorslockedpercm = np.true_divide(doorslockedm.values, doorslockedm.sum())*100
doorslockedpercm
Out[94]:
array([37.14285714, 62.85714286])
In [95]:
computersm =midsafe_subs['Computers, televisions and other electronics not visible from outside'].value_counts().sort_index()
computerspercm =np.true_divide(computersm.values, computersm.sum())*100
computerspercm
Out[95]:
array([31.42857143, 68.57142857])
In [96]:
doorseenm = midsafe_subs['Front door and entry can be seen from street'].value_counts().sort_index()
doorseenpercm =np.true_divide(doorseenm.values, doorseenm.sum())*100
doorseenpercm
Out[96]:
array([24.36090226, 75.63909774])
In [97]:
housenumm = midsafe_subs['House number is clearly displayed'].value_counts().sort_index()
housenumpercm =np.true_divide(housenumm.values, housenumm.sum())*100
housenumpercm
Out[97]:
array([ 4.21052632, 95.78947368])
In [98]:
housenumvism = midsafe_subs['House number is visible at night'].value_counts().sort_index()
housenumvispercm =np.true_divide(housenumvism.values, housenumvism.sum())*100
housenumvispercm
Out[98]:
array([36.09022556, 63.90977444])
In [99]:
gardm = midsafe_subs['Garden kept short and neat'].value_counts().sort_index()
gardpercm =np.true_divide(gardm.values, gardm.sum())*100
gardpercm
Out[99]:
array([24.36090226, 75.63909774])
In [100]:
cameram= midsafe_subs['Security camera faces entry'].value_counts().sort_index()
campercm = np.true_divide(cameram.values, cameram.sum())*100
campercm
Out[100]:
array([71.12781955, 28.87218045])
In [101]:
dogm= midsafe_subs['I have a dog'].value_counts().sort_index()
dogpercm = np.true_divide(dogm.values, dogm.sum())*100
dogpercm
Out[101]:
array([67.51879699, 32.48120301])
In [102]:
sensorlightm= midsafe_subs['I have sensor lighting or timed lighting in my house for when I’m not at home'].value_counts().sort_index()
sensorlightpercm = np.true_divide(sensorlightm.values, sensorlightm.sum())*100
sensorlightpercm
Out[102]:
array([34.73684211, 65.26315789])
In [103]:
valuem= midsafe_subs['Valuables kept in a secured, locked safe located out of sight.'].value_counts().sort_index()
valuepercm = np.true_divide(valuem.values, valuem.sum())*100
valuepercm
Out[103]:
array([61.95488722, 38.04511278])
In [104]:
col_names = ["No",'Yes'] 
results = { 'Front door seen from street': doorseenpercm,
           'House number is clearly displayed': housenumpercm,
           'House number is visible at night': housenumvispercm,
           "Doors and windows locked": doorslockedpercm,
           'Electronics out of sight': computerspercm,
          'Garden kept short and neat': gardpercm,
           'Sensor/timed lighting when not at home': sensorlightpercm,
           'Security camera at home': campercm,
           'Dog at home': dogpercm,
           'Valuables kept in a secured & locked safe': valuepercm}
def survey(results, col_names):
    labels = list(results.keys())
    data = np.array(list(results.values()))
    data_cum = data.cumsum(axis=1)
    category_colors = plt.get_cmap('RdYlGn')(np.linspace(0.1, 0.90, data.shape[1]))
    fig, ax = plt.subplots(figsize=(9.9, 3.7))
    ax.invert_yaxis()
    ax.xaxis.set_visible(False)
    ax.set_xlim(0, np.sum(data, axis=1).max())
    for i, (colname, color) in enumerate(zip(col_names, category_colors)):
        widths = data[:, i]
        starts = data_cum[:, i] - widths
        ax.barh(labels, widths, left=starts, height=0.9, label=colname, color=color)
        xcenters = starts + widths / 2
        r, g, b, _ = color
        text_color = 'black' 
        for y, (x, c) in enumerate(zip(xcenters, widths)):
            ax.text(x, y, str(int(c)), ha='center', va='center',
                    color=text_color)
    ax.legend(ncol=len(col_names), bbox_to_anchor=(0.42, -0.15),
              loc='lower left', fontsize='small')
    return fig, ax
     
survey(results, col_names) 
plt.title("House security measures (in %)")

fig.tight_layout()
plt.show()

Unsafe/least safe suburbs with safety rating between 6 to 1

In [105]:
#Filter 6 to 1 safety rating
nsafe_subs = merged1_copy[merged1_copy.rating.isin([1,2,3,4,5,6])]

print(nsafe_subs.shape)
nsafe_subs.head()
(214, 16)
Out[105]:
suburb rating postcode cnt LC_PLY_PID DT_CREATE DT_RETIRE LOC_PID VIC_LOCALI VIC_LOCA_1 VIC_LOCA_3 VIC_LOCA_4 VIC_LOCA_5 VIC_LOCA_6 VIC_LOCA_7 geometry
11 mornington 5.0 3931 0 6647 2011-08-31 None VIC1757 2012-04-27 None None None G None 2 POLYGON ((145.06100227 -38.20092728, 145.06127...
16 hoppers crossing 5.0 3029 0 9942 2013-11-26 None VIC1195 2013-08-05 None None None G None 2 POLYGON ((144.66510003 -37.87181902, 144.66512...
18 belvedere park 2.0 3198 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN None
19 bell park 5.0 3215 0 6818 2011-08-31 None VIC191 2012-04-27 None None None G None 2 POLYGON ((144.33340302 -38.11969903, 144.33326...
21 glenroy 6.0 3046 0 10989 2018-03-05 None VIC1037 2018-05-12 None None None G None 2 POLYGON ((144.937074 -37.71103003, 144.9372779...
In [106]:
len(nsafe_subs['suburb'].unique())
Out[106]:
126
In [107]:
table2 = nsafe_subs[['suburb', 'rating', 'postcode']].sort_values(by = 'suburb', ascending = True)
In [108]:
table2 = table2.drop_duplicates(subset='suburb', keep='first')
table2_1 =table2.iloc[0:34]
table2_2 =table2.iloc[34:68]
table2_3 =table2.iloc[68:120]
In [109]:
import six
def render_mpl_table(data, col_width=3.0, row_height=0.625, font_size=14,
                     header_color='lightseagreen', row_colors=['#f1f1f2', 'w'], edge_color='w',
                     bbox=[0, 0, 1, 1], header_columns=0,
                     ax=None, **kwargs):
    if ax is None:
        size = (np.array(data.shape[::-1]) + np.array([0, 1])) * np.array([col_width, row_height])
        fig, ax = plt.subplots(figsize=size)
        ax.axis('off')

    mpl_table = ax.table(cellText=data.values, bbox=bbox, colLabels=data.columns, **kwargs)

    mpl_table.auto_set_font_size(False)
    mpl_table.set_fontsize(font_size)

    for k, cell in six.iteritems(mpl_table._cells):
        cell.set_edgecolor(edge_color)
        if k[0] == 0 or k[1] < header_columns:
            cell.set_text_props(weight='bold', color='w')
            cell.set_facecolor(header_color)
        else:
            cell.set_facecolor(row_colors[k[0]%len(row_colors) ])
    return ax

render_mpl_table(table2_3, header_columns=0, col_width=2.5)
Out[109]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fe29248fda0>
In [110]:
#Filter 1 to 6 safety rating
notsafe_subs =slide3[slide3.rating.isin([1,2,3,4,5,6])]

print(notsafe_subs.shape)
notsafe_subs.head()
(214, 44)
Out[110]:
Postcode rating What type of home do you live in? Which of the following external doors does your home have? How well do you know your neighbours? Keys stored out of sight in a secret spot. Spare keys not hidden in obvious places outside the home Keys not kept in locks when not at home Spare key kept with trusted friend, relative or neighbour Does your home have any security systems? ... Do you have any outdoor buildings such as sheds, a studio or granny flat? Which of these security measures do you have on your outdoor buildings Does your home have an enclosed garage? What security measures do you have in place for your garage cnt_x suburb state lat lon cnt_y
11 3931 5.0 House Front door, Rear door, Side door(s) I know them very well and leave a spare key wi... No Response Yes Yes Yes No Response ... No Response No Response No Response No Response 0 MORNINGTON VIC -38.238386 145.064195 0.0
16 3029 5.0 House Front door, Rear door, Side door(s) I know them to say hello and we talk occasiona... No Response Yes Yes Yes No ... Yes Building secured to ground, Lockable door bolt No No Response 0 HOPPERS CROSSING VIC -37.882636 144.700297 0.0
18 3198 2.0 House Front door, Rear door, Side door(s) I don’t know them No Response Yes Yes Yes No ... No No Response Yes All garage doors are kept locked when not in use 0 BELVEDERE PARK VIC -38.106670 145.158496 0.0
19 3215 5.0 House Front door, Rear door I know them to say hello and we talk occasiona... No Response Yes Yes Yes No ... Yes Building secured to ground, Lockable door bolt Yes All garage doors are kept locked when not in use 0 BELL PARK VIC -38.113738 144.330983 0.0
21 3046 6.0 House Front door, Rear door I know them to say hello and we talk occasiona... No Response No No No Yes ... No No Response Yes Door remote not stored in car, All garage door... 0 GLENROY VIC -37.704581 144.915758 0.0

5 rows × 44 columns

In [111]:
table2 = notsafe_subs.drop_duplicates(subset='suburb', keep='first')
In [112]:
len(notsafe_subs['suburb'].unique())
Out[112]:
126

Type of Home

In [113]:
notsafe_subs['What type of home do you live in?'].value_counts().sort_values()
Out[113]:
Farm                2
Apartment           4
Unit/Townhouse     39
House             169
Name: What type of home do you live in?, dtype: int64
In [114]:
ndf_piechart1 = notsafe_subs['What type of home do you live in?'].value_counts().sort_values()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = ndf_piechart1.index
sizes = ndf_piechart1.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.85, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Type of Home (in %)")
Out[114]:
Text(0.5, 1.0, 'Type of Home (in %)')

Type of Doors

In [115]:
ndf_piechart2 = notsafe_subs['Which of the following external doors does your home have?'].value_counts().sort_values()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = ndf_piechart2.index
sizes = ndf_piechart2.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.85, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Type of External Doors (in %)")
Out[115]:
Text(0.5, 1.0, 'Type of External Doors (in %)')

Type of Fences

In [116]:
ndf_piechart3 = notsafe_subs['What fences does your property have?'].value_counts().sort_values()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = ndf_piechart3.index
sizes = ndf_piechart3.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.9, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Fences in the House(in %)")
Out[116]:
Text(0.5, 1.0, 'Fences in the House(in %)')

Security alarms at home

In [117]:
ndf_piechart5 = notsafe_subs['Security camera faces entry'].value_counts().sort_index()
def autopct_generator(limit):
    """Remove percent on small slices."""
    def inner_autopct(pct):
        return ('%.2f%%' % pct) if pct > limit else ''
    return inner_autopct

labels = ndf_piechart5.index
sizes = ndf_piechart5.values
NUM_COLORS = len(sizes)

fig1, ax1 = plt.subplots(figsize=(6, 5))

#theme = plt.get_cmap('YlGn')
theme = plt.get_cmap('RdYlGn')
ax1.set_prop_cycle("color", [theme(1. * i / len(sizes)) for i in range(len(sizes))])

box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * 1.3, box.height])

_, _, autotexts = ax1.pie(
    sizes, autopct=autopct_generator(7), startangle=90, radius=1.8 * 1000)
for autotext in autotexts:
    autotext.set_weight('bold')
ax1.axis('equal')
total = sum(sizes)
plt.legend(
    loc='upper left',
    labels=['%s, %1.1f%%' % (
        l, (float(s) / total) * 100) for l, s in zip(labels, sizes)],
    prop={'size': 11},
    bbox_to_anchor=(0.85, 1),
    bbox_transform=fig1.transFigure
)

plt.title("Does your home have any\n security systems? (in %)")
Out[117]:
Text(0.5, 1.0, 'Does your home have any\n security systems? (in %)')

House security measures

In [118]:
doorslockedn = notsafe_subs['I keep all my doors and windows locked when I’m at home or in my yard'].value_counts().sort_index()
doorslockedpercn = np.true_divide(doorslockedn.values, doorslockedn.sum())*100
doorslockedpercn
Out[118]:
array([38.31775701, 61.68224299])
In [119]:
computersn =notsafe_subs['Computers, televisions and other electronics not visible from outside'].value_counts().sort_index()
computerspercn =np.true_divide(computersn.values, computersn.sum())*100
computerspercn
Out[119]:
array([34.11214953, 65.88785047])
In [120]:
doorseenn = notsafe_subs['Front door and entry can be seen from street'].value_counts().sort_index()
doorseenpercn =np.true_divide(doorseenn.values, doorseenn.sum())*100
doorseenpercn
Out[120]:
array([30.37383178, 69.62616822])
In [121]:
housenumn = notsafe_subs['House number is clearly displayed'].value_counts().sort_index()
housenumpercn =np.true_divide(housenumn.values, housenumn.sum())*100
housenumpercn
Out[121]:
array([11.68224299, 88.31775701])
In [122]:
housenumvisn =notsafe_subs['House number is visible at night'].value_counts().sort_index()
housenumvisn = housenumvisn.iloc[[0,2],]
In [123]:
#housenumvisn = notsafe_subs['House number is visible at night'].value_counts().sort_index()
housenumvispercn =np.true_divide(housenumvisn.values, housenumvisn.sum())*100
housenumvispercn
Out[123]:
array([49.76525822, 50.23474178])
In [124]:
gardn = notsafe_subs['Garden kept short and neat'].value_counts().sort_index()
gardpercn =np.true_divide(gardn.values, gardn.sum())*100
gardpercn
Out[124]:
array([30.37383178, 69.62616822])
In [125]:
cameran= notsafe_subs['Security camera faces entry'].value_counts().sort_index()
campercn = np.true_divide(cameran.values, cameran.sum())*100
campercn
Out[125]:
array([74.29906542, 25.70093458])
In [126]:
dogn= notsafe_subs['I have a dog'].value_counts().sort_index()
dogpercn = np.true_divide(dogn.values, dogn.sum())*100
dogpercn
Out[126]:
array([70.56074766, 29.43925234])
In [127]:
sensorlightn= notsafe_subs['I have sensor lighting or timed lighting in my house for when I’m not at home'].value_counts().sort_index()
sensorlightpercn = np.true_divide(sensorlightn.values, sensorlightn.sum())*100
sensorlightpercn
Out[127]:
array([39.71962617, 60.28037383])
In [128]:
valuen= notsafe_subs['Valuables kept in a secured, locked safe located out of sight.'].value_counts().sort_index()
valuepercn = np.true_divide(valuen.values, valuen.sum())*100
valuepercn
Out[128]:
array([60.28037383, 39.71962617])
In [129]:
col_names = ["No",'Yes'] 
results = { 'Front door seen from street': doorseenpercn,
           'House number is clearly displayed': housenumpercn,
           'House number is visible at night': housenumvispercn,
           "Doors and windows locked": doorslockedpercn,
           'Electronics out of sight': computerspercn,
          'Garden kept short and neat': gardpercn,
           'Sensor/timed lighting when not at home': sensorlightpercn,
           'Security camera at home': campercn,
           'Dog at home': dogpercn,
           'Valuables kept in a secured & locked safe': valuepercn}
def survey(results, col_names):
    labels = list(results.keys())
    data = np.array(list(results.values()))
    data_cum = data.cumsum(axis=1)
    category_colors = plt.get_cmap('RdYlGn')(np.linspace(0.1, 0.90, data.shape[1]))
    fig, ax = plt.subplots(figsize=(9.9, 3.7))
    ax.invert_yaxis()
    ax.xaxis.set_visible(False)
    ax.set_xlim(0, np.sum(data, axis=1).max())
    for i, (colname, color) in enumerate(zip(col_names, category_colors)):
        widths = data[:, i]
        starts = data_cum[:, i] - widths
        ax.barh(labels, widths, left=starts, height=0.9, label=colname, color=color)
        xcenters = starts + widths / 2
        r, g, b, _ = color
        text_color = 'black' 
        for y, (x, c) in enumerate(zip(xcenters, widths)):
            ax.text(x, y, str(int(c)), ha='center', va='center',
                    color=text_color)
    ax.legend(ncol=len(col_names), bbox_to_anchor=(0.42, -0.15),
              loc='lower left', fontsize='small')
    return fig, ax
     
survey(results, col_names) 
plt.title("House security measures (in %)")

fig.tight_layout()
plt.show()
fig.savefig('plot5.pdf')